package com.example.web;

import com.alibaba.fastjson.JSONObject;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Classname TestController
 * @Description TODO
 * @Date 2022/3/22 14:34
 * @Created by XiongXiong
 * @Author: X.I.O
 */
@RestController
@RequestMapping("test")
public class TestController {

    @GetMapping("get")
    public JSONObject testJSonObjectMap(){
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        System.out.println(JSONObject.toJSONString(authentication));
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("code",1);
        jsonObject.put("msg","hello word");
        return jsonObject;
    }
}
